/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ppsa.dao;

import com.ppsa.bean.AreaBean;
import com.ppsa.bean.EmpleadoBean;
import com.ppsa.bean.PerfilBean;
import com.ppsa.bean.ReunionBean;
import com.ppsa.bean.TareaBean;
import com.ppsa.common.Constantes;
import java.util.List;


import java.sql.DriverManager;
import java.sql.ResultSet;
import java.util.ArrayList;
import org.apache.log4j.Logger;

/**
 *
 * @author AdminTdp
 */
public class AreaDao extends AccesoDao {

    static final Logger m_log = Logger.getLogger(AreaDao.class.getName());

    public AreaDao() throws AccesoDaoException {
        super();
    }

    public List<AreaBean> listarArea( String strpv_codigoEmpresa ) throws Exception {
        List<AreaBean> lstL_Area = new ArrayList<AreaBean>();

        AreaBean objL_area = null;
        //TareaBean objL_tarea = null;
        try {
            //this.objPt_conn = objPt_dataSource.getConnection();
            this.objPt_conn = DriverManager.getConnection(strpv_conexionUrl);
            String strl_procedure = "{ call ppsa_sp_listarAreaEmpresa(?) }";
            m_log.info("strpv_codigoEmpresa---->" +strpv_codigoEmpresa);

            objPt_cstmt = objPt_conn.prepareCall(strl_procedure);
            objPt_cstmt.setString(1, strpv_codigoEmpresa);
            objPt_rs = objPt_cstmt.executeQuery();
            while( objPt_rs.next() ) {
                objL_area = new AreaBean();
                
                objL_area.setStrpv_codigoArea(strpv_codigoEmpresa);
                objL_area.setStrpv_codigoArea(objPt_rs.getString("ID_AREA"));
                objL_area.setStrpv_nombreArea(objPt_rs.getString("NOMBRE"));
           
                lstL_Area.add(objL_area);
            }
        } catch ( Exception ex ) {
            ex.printStackTrace();
        } finally {
            closeCallableStatement(objPt_cstmt);
            closeResultSet(objPt_rs);
            closeConnection(objPt_conn);
        }
        return lstL_Area;
    }
}
